package com.xinshujia.handler;

import com.xinshujia.utils.HttpServletResponseUtil;
import com.xinshujia.utils.response.RespResult;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author: 野狼上校
 * @create: 2023-06-05  21:26
 * @version: 1.0
 * @description: 退出成功处理器
 */
@Component
public class MyLogoutSuccessHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        HttpServletResponseUtil httpServletResponseUtil = new HttpServletResponseUtil();
        RespResult result = RespResult.OK("退出成功");
        httpServletResponseUtil.responseAuthenticationResult(response, result);
    }
}
